﻿// // ******************************************************************
// //       /\ /|       @file       StreamExtensions.cs
// //       \ V/        @brief      await29
// //       | "")       @author     Await, 285283010@qq.com
// //       /  |
// //      /  \\        @Modified   2025-01-07 21:01
// //    *(__\_\        @Copyright  Copyright (c) , 2025-01-07 21:01 Await
// // ******************************************************************

namespace AutomaticSubtitles.Service.Infrastructure.Helper;

public static class StreamExtensions
{
    public static async Task PipeToAsync(this StreamReader reader, StreamWriter writer)
    {
        var buffer = new char[4096];
        int bytesRead;
        while ((bytesRead = await reader.ReadAsync(buffer, 0, buffer.Length)) > 0)
        {
            await writer.WriteAsync(buffer, 0, bytesRead);
            await writer.FlushAsync();
        }
    }
}